home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / warcraft / code.lua next >
Encoding:
Text File  |  2005-07-16  |  9.2 KB  |  302 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky09.ogg")
  8.     local pokus = getRestartCount()
  9.  
  10.  
  11.     -- -------------------------------------------------------------
  12.     local function prog_init_room()
  13.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  14.  
  15.         if pokus == 1 then
  16.             room.uvod = 3
  17.         else
  18.             room.uvod = random(3)
  19.         end
  20.         room.oregistry = random(5000) + 500
  21.         room.odolech = 0
  22.         room.oblizardu = 0
  23.  
  24.         return function()
  25.             if room.oblizardu == 0 and isReady(big) and big.X == 47 and big.Y == 11 then
  26.                 room.oblizardu = 1
  27.                 big:setBusy(true)
  28.                 addv(5, "war-v-blizzard")
  29.                 if isReady(small) then
  30.                     small:setBusy(true)
  31.                     addm(4, "war-m-hodiny")
  32.                 end
  33.                 planBusy(big, false)
  34.                 planBusy(small, false)
  35.             end
  36.             if no_dialog() and isReady(small) and isReady(big) then
  37.                 for pom1 = 1, 10 do
  38.                     if room.oregistry > 0 then
  39.                         room.oregistry = room.oregistry - 1
  40.                     end
  41.                 end
  42.                 if room.uvod > 0 then
  43.                     if room.uvod == 1 or room.uvod == 3 then
  44.                         addm(random(30) + 10, "war-m-kam")
  45.                         addv(random(30) + 10, "war-v-povedome")
  46.                     end
  47.                     if room.uvod == 2 or room.uvod == 3 then
  48.                         switch(random(2)){
  49.                             [0] = function()
  50.                                 addm(random(30) + 20, "war-m-hrad")
  51.                             end,
  52.                             [1] = function()
  53.                                 addm(random(30) + 20, "war-m-ocel")
  54.                             end,
  55.                         }
  56.                         if random(100) < 50 or pokus == 1 then
  57.                             addv(random(200) + 10, "war-v-vesnicane")
  58.                             addm(4, "war-m-peoni")
  59.                         end
  60.                     end
  61.                     room.uvod = 0
  62.                 elseif room.odolech == 0 and (dul1.dir ~= dir_no or dul2.dir ~= dir_no) and random(100) < 10 then
  63.                     room.odolech = 0
  64.                     addv(random(30) + 10, "war-v-doly")
  65.                     addm(random(20), "war-m-povazuji")
  66.                 elseif room.oregistry == 0 then
  67.                     room.oregistry = -1
  68.                     addv(20, "war-v-pohadka")
  69.                     addm(random(40) + 10, "war-m-pichat")
  70.                     addv(2, "war-v-prozradit")
  71.                     addm(4, "war-m-aznato")
  72.                 end
  73.             end
  74.         end
  75.     end
  76.  
  77.     -- -------------------------------------------------------------
  78.     local function prog_init_knight1()
  79.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  80.  
  81.         knight1.hybese = 0
  82.         knight1.unejvelka = 1
  83.         knight1.unejmala = 0
  84.  
  85.         return function()
  86.             pom2 = 0
  87.             if dist(big, knight1) <= 1 then
  88.                 pom1 = 1
  89.             else
  90.                 pom1 = 0
  91.             end
  92.             if knight1.unejvelka == 0 and pom1 == 1 then
  93.                 pom2 = 1
  94.             end
  95.             knight1.unejvelka = pom1
  96.             if dist(small, knight1) <= 1 then
  97.                 pom1 = 1
  98.             else
  99.                 pom1 = 0
  100.             end
  101.             if knight1.unejmala == 0 and pom1 == 1 then
  102.                 pom2 = 1
  103.             end
  104.             knight1.unejmala = pom1
  105.             if knight1.dir ~= dir_no and knight1.hybese == 0 then
  106.                 pom2 = 2
  107.             end
  108.             if knight1.dir ~= dir_no then
  109.                 knight1.hybese = 1
  110.             else
  111.                 knight1.hybese = 0
  112.             end
  113.             switch(pom2){
  114.                 [1] = function()
  115.                     knight1:talk("war-k-ready"..random(3), VOLUME_FULL)
  116.                 end,
  117.                 [2] = function()
  118.                     knight1:talk("war-k-move" ..random(3), VOLUME_FULL)
  119.                 end,
  120.             }
  121.         end
  122.     end
  123.  
  124.     -- -------------------------------------------------------------
  125.     local function prog_init_knight2()
  126.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  127.  
  128.         knight2.hybese = 0
  129.         knight2.unejvelka = 0
  130.         knight2.unejmala = 0
  131.  
  132.         return function()
  133.             pom2 = 0
  134.             if dist(big, knight2) <= 1 then
  135.                 pom1 = 1
  136.             else
  137.                 pom1 = 0
  138.             end
  139.             if knight2.unejvelka == 0 and pom1 == 1 then
  140.                 pom2 = 1
  141.             end
  142.             knight2.unejvelka = pom1
  143.             if dist(small, knight2) <= 1 then
  144.                 pom1 = 1
  145.             else
  146.                 pom1 = 0
  147.             end
  148.             if knight2.unejmala == 0 and pom1 == 1 then
  149.                 pom2 = 1
  150.             end
  151.             knight2.unejmala = pom1
  152.             if knight2.dir ~= dir_no and knight2.hybese == 0 then
  153.                 pom2 = 2
  154.             end
  155.             if knight2.dir ~= dir_no then
  156.                 knight2.hybese = 1
  157.             else
  158.                 knight2.hybese = 0
  159.             end
  160.             switch(pom2){
  161.                 [1] = function()
  162.                     knight2:talk("war-k-ready"..random(3), VOLUME_FULL)
  163.                 end,
  164.                 [2] = function()
  165.                     knight2:talk("war-k-move"..random(3), VOLUME_FULL)
  166.                 end,
  167.             }
  168.         end
  169.     end
  170.  
  171.     -- -------------------------------------------------------------
  172.     local function prog_init_archer1()
  173.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  174.  
  175.         archer1.hybese = 0
  176.         archer1.unejvelka = 1
  177.         archer1.unejmala = 0
  178.  
  179.         return function()
  180.             pom2 = 0
  181.             if dist(big, archer1) <= 1 then
  182.                 pom1 = 1
  183.             else
  184.                 pom1 = 0
  185.             end
  186.             if archer1.unejvelka == 0 and pom1 == 1 then
  187.                 pom2 = 1
  188.             end
  189.             archer1.unejvelka = pom1
  190.             if dist(small, archer1) <= 1 then
  191.                 pom1 = 1
  192.             else
  193.                 pom1 = 0
  194.             end
  195.             if archer1.unejmala == 0 and pom1 == 1 then
  196.                 pom2 = 1
  197.             end
  198.             archer1.unejmala = pom1
  199.             if archer1.dir ~= dir_no and archer1.hybese == 0 then
  200.                 pom2 = 2
  201.             end
  202.             if archer1.dir ~= dir_no then
  203.                 archer1.hybese = 1
  204.             else
  205.                 archer1.hybese = 0
  206.             end
  207.             switch(pom2){
  208.                 [1] = function()
  209.                     archer1:talk("war-a-ready"..random(2), VOLUME_FULL)
  210.                 end,
  211.                 [2] = function()
  212.                     archer1:talk("war-a-move"..random(2), VOLUME_FULL)
  213.                 end,
  214.             }
  215.         end
  216.     end
  217.  
  218.     -- -------------------------------------------------------------
  219.     local function prog_init_archer2()
  220.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  221.  
  222.         archer2.hybese = 0
  223.         archer2.unejvelka = 1
  224.         archer2.unejmala = 0
  225.  
  226.         return function()
  227.             pom2 = 0
  228.             if dist(big, archer2) <= 1 then
  229.                 pom1 = 1
  230.             else
  231.                 pom1 = 0
  232.             end
  233.             if archer2.unejvelka == 0 and pom1 == 1 then
  234.                 pom2 = 1
  235.             end
  236.             archer2.unejvelka = pom1
  237.             if dist(small, archer2) <= 1 then
  238.                 pom1 = 1
  239.             else
  240.                 pom1 = 0
  241.             end
  242.             if archer2.unejmala == 0 and pom1 == 1 then
  243.                 pom2 = 1
  244.             end
  245.             archer2.unejmala = pom1
  246.             if archer2.dir ~= dir_no and archer2.hybese == 0 then
  247.                 pom2 = 2
  248.             end
  249.             if archer2.dir ~= dir_no then
  250.                 archer2.hybese = 1
  251.             else
  252.                 archer2.hybese = 0
  253.             end
  254.             switch(pom2){
  255.                 [1] = function()
  256.                     archer2:talk("war-a-ready"..random(2), VOLUME_FULL)
  257.                 end,
  258.                 [2] = function()
  259.                     archer2:talk("war-a-move"..random(2), VOLUME_FULL)
  260.                 end,
  261.             }
  262.         end
  263.     end
  264.  
  265.     -- --------------------
  266.     local update_table = {}
  267.     local subinit
  268.     subinit = prog_init_room()
  269.     if subinit then
  270.         table.insert(update_table, subinit)
  271.     end
  272.     subinit = prog_init_knight1()
  273.     if subinit then
  274.         table.insert(update_table, subinit)
  275.     end
  276.     subinit = prog_init_knight2()
  277.     if subinit then
  278.         table.insert(update_table, subinit)
  279.     end
  280.     subinit = prog_init_archer1()
  281.     if subinit then
  282.         table.insert(update_table, subinit)
  283.     end
  284.     subinit = prog_init_archer2()
  285.     if subinit then
  286.         table.insert(update_table, subinit)
  287.     end
  288.     return update_table
  289. end
  290. local update_table = prog_init()
  291.  
  292.  
  293. -- -----------------------------------------------------------------
  294. -- Update
  295. -- -----------------------------------------------------------------
  296. function prog_update()
  297.     for key, subupdate in pairs(update_table) do
  298.         subupdate()
  299.     end
  300. end
  301.  
  302.